package src.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;

import src.view.ViewHandler.DisplayType;

/**
 * <b>Overview</b>
 * The TurnViewport is displayed between player turns so that one player does not see the other player's position during the switch in control.
 *
 * <b>Responsibilities</b>
 * Prevent the last player from seeing the next player's position.
 *
 * <b>Collaborators</b>
 * Drawable - Subcontractor: The Drawable object will display the blocking image to allow players to change.
 *
 * <b>Implementor</b> - Bruce
 * <b>Tester</b> - Tim
 *
 * @author Bruce
 */
public class TurnViewport extends Viewport
{
	/**
	 * Creates a new TurnViewport.
	 *
	 * @param canvas the Drawable on which to display this viewport.
	 */
	public TurnViewport(ViewHandler vh, Drawable canvas)
	{
		super(vh, canvas, DisplayType.NEWTURN);
	}

	/* (non-Javadoc)
	 * @see src.view.Viewport#draw()
	 */
	@Override
	protected void draw()
	{
		try
		{
			// Background
			BufferedImage image = ImageIO.read(new File("images/ship.png"));
			AffineTransform at = new AffineTransform();
			at.scale((double)getWidth() / (double)image.getWidth(), (double)getHeight() / (double)image.getHeight());
			getCanvas().drawImage(image, at, null);
		}
		catch(Exception e) {}

		drawString("Switch pirates!", getWidth() / 2 - 100, getHeight() / 2 - 50, Color.BLACK, Color.WHITE, 28);
	}

	/* (non-Javadoc)
	 * @see src.view.Viewport#getResizeDimension()
	 */
	@Override
	protected Dimension getResizeDimension()
	{
		return getCanvasDimensions();
	}

	/* (non-Javadoc)
	 * @see src.view.Viewport#getResizePoint()
	 */
	@Override
	protected Point2D getResizePoint()
	{
		return Point2D.origin();
	}
}